"""
@Author: li
@Email: lijianqiao2906@live.com
@FileName: auth.py
@DateTime: 2025/07/06
@Docs: 认证与授权相关的 Pydantic Schema
"""

from pydantic import BaseModel, EmailStr, Field

from app.schemas.base import BaseRequest
from app.schemas.user import UserRead


class LoginRequest(BaseRequest):
    """登录请求 Schema"""

    username: str | EmailStr = Field(description="用户名或邮箱")
    password: str = Field(description="密码")


class TokenPayload(BaseModel):
    """JWT 令牌负载数据"""

    sub: int | str = Field(description="令牌主题 (通常是用户ID)")
    exp: int = Field(description="令牌过期时间戳")


class TokenResponse(BaseModel):
    """令牌响应 Schema"""

    access_token: str = Field(description="访问令牌")
    token_type: str = Field(default="bearer", description="令牌类型")
    expires_in: int = Field(description="令牌有效期（秒）")


class LoginResponse(BaseModel):
    """登录成功响应 Schema"""

    token: TokenResponse = Field(description="令牌信息")
    user: UserRead = Field(description="用户信息")
